﻿using MediatR;
using W.Carrier.Api.Application.Command;
using W.Carrier.Repostiory.Interface;

namespace W.Carrier.Api.Application.CommandHandler
{
    public class CarrierUpdateCommandHandler : IRequestHandler<CarrierUpdateCommand, int>
    {
        private readonly ICarrierInfoRepository _icarrierInfoRepository;
        public CarrierUpdateCommandHandler(ICarrierInfoRepository icarrierInfoRepository)
        {
            _icarrierInfoRepository = icarrierInfoRepository;
        }

        public async Task<int> Handle(CarrierUpdateCommand request, CancellationToken cancellationToken)
        {
            return await _icarrierInfoRepository.Update(new Domain.CarrierInfo
            {
                CarrierId = request.CarrierId,
                CarrierNo = request.CarrierNo,
                CarrierName = request.CarrierName,
                CarrierRemarks = request.CarrierRemarks,
                officeId = request.officeId,
                userid = request.userid,
                CreateName = request.CreateName,
                CreateTime = DateTime.Now,
                UpdateName = request.UpdateName,
                UpdateTime = DateTime.Now,
                IsDelete = false,
            });
        }
    }
}
